package com.kmust.dream.wanderingdream.donation.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
//                .enable(false)
//                配置API文档的分组
                .groupName("Hrd")
                .select()
//                RequestHandlerSelectors配置要扫描接口的方式
//                basePackage指定要扫描的包
//                any()扫描全部
//                none()不扫描
//                paths()过滤什么路径
                .apis(RequestHandlerSelectors.basePackage("com.kmust.dream.wanderingdream.donation.controller"))
                .build();
    }

    //配置文档信息
    private ApiInfo apiInfo() {
        Contact contact = new Contact("Kmust Leng", "https://www.baidu.com/", "Leng81605@gmail.com");
        return new ApiInfo(
                "捐赠模块API", // 标题
                "捐赠模块的api细分", // 描述
                "v1.0", // 版本
                "https://www.baidu.com/", // 组织链接
                contact, // 联系人信息
                "Apach 2.0 许可", // 许可
                "许可链接", // 许可连接
                new ArrayList<>()// 扩展
        );
    }
}
